/**
 *
 * @author cheng sir
 * 2016年9月8日下午7:47:53
 */
package com.angel.web.sys;

import java.util.List;
import java.util.Map;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.angel.core.Constants;
import com.angel.core.base.JsonEntity;
import com.angel.core.util.JsonUtil;
import com.angel.core.util.Pager;
import com.angel.core.util.SMSUtils;
import com.angel.health.BuzCustomer;
import com.angel.health.SMS;
import com.angel.health.SysArea;
import com.angel.health.SysAreaExt;
import com.angel.health.SysSendMessage;
import com.angel.provider.health.BuzCustomerProvider;
import com.angel.provider.sys.SysSendMessageProvider;

/**
 * @author cheng sir
 * 2016年9月8日下午7:47:53
 */
@Controller
@RequestMapping("sysSendMessage")
public class SysSendMessageController {
	
	@Autowired
	private SysSendMessageProvider sysSendMessageProvider;
	@Autowired
	private BuzCustomerProvider customerService;

	/**
	 * 
	 * @param memPhone
	 * @param type  1.注册 2.找回密码
	 * @return
	 */
//	@ResponseBody
//	@RequestMapping(value="getCode", produces = "application/json; charset=utf-8")
//	public String getCode(String memPhone,String type){
//		if(StringUtils.isEmpty(memPhone)){
//			return JsonUtil.toJson(new JsonEntity("-1","手机号不存在！"));
//		}
//		String content = "为您在天使健康的找回密码验证码【天使健康】";
//		BuzCustomer buzCustomer = new BuzCustomer();
//		buzCustomer.setMemPhone(memPhone);
//		List<Map<String,Object>> list = customerService.findAll(buzCustomer);
//		if("1".equals(type)){
//			content = "为您在天使健康的注册验证码【天使健康】";
//			if(list.size() > 0){
//				return JsonUtil.toJson(new JsonEntity("-1","已注册"));
//			}
//		}else{
//			if(list.size() == 0){
//				return JsonUtil.toJson(new JsonEntity("-1","未注册"));
//			}
//		}
//		String code = "";
//		Random random = new Random();
//		for(int i = 0;i<4;i++){
//			int nextInt = random.nextInt(10);
//			code += nextInt;
//		}
//		content = code+content;
//		SysSendMessage sysSendMessage = new SysSendMessage(1,memPhone,content,null);
//		int insert = sysSendMessageProvider.insert(sysSendMessage);
//		if(insert > 0){
//			String single = Constants.SEND_SMS_SINGLE;
//			JsonEntity json = SMSUtils.send(new SMS(sysSendMessage.getId().toString(),memPhone,content,sysSendMessage.getId().toString(),""),single);
//			if("200".equals(json.getCode())){
//				return JsonUtil.toJson(new JsonEntity("200",code));
//			}
//			return JsonUtil.toJson(json);
//		}
//		return JsonUtil.toJson(new JsonEntity("-1","发送失败！"));
//	}
	
}
